package edu.uw.tcss360.group6.gui;

import javax.swing.*;
import java.awt.*;

/**
 * Created with IntelliJ IDEA.
 * edu.uw.tcss360.group6.model.User: Lemtzas
 * Date: 2/20/13
 * Time: 9:18 PM
 * To change this template use File | Settings | File Templates.
 */
@SuppressWarnings("serial")
public class LogPanel extends JPanel {
    private static final int PREFERRED_WIDTH  = 150;
    private static final int PREFERRED_HEIGHT = 350;

    private static final String INTRO_TEXT = "Welcome to BeWeavers automation.";

    private final JTextArea my_text_area;

    public LogPanel() {
        super(new BorderLayout());
        my_text_area = new JTextArea(INTRO_TEXT,21,20);
        my_text_area.setLineWrap(true);
        my_text_area.setWrapStyleWord(true);
        my_text_area.setEditable(false);

        this.setBackground(Color.BLACK);
        this.setPreferredSize(new Dimension(PREFERRED_WIDTH,PREFERRED_HEIGHT));
        JScrollPane jsp = new JScrollPane(my_text_area,JScrollPane.VERTICAL_SCROLLBAR_NEVER,JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        jsp.setAutoscrolls(true);
        //TODO: Erase previous text when scroll goes too far
        this.add(jsp,BorderLayout.CENTER);
    }

    public void log(String text) {
        my_text_area.append("\n\n" + text);
    }

    @Override
    public Insets getInsets()
    {
        return new Insets(3,0,0,0);
    }
}
